package bairui.international.controller.user.offset;

/**
 * @see bairui.international.controller.user.offset.Page_BaseFilter
 *
 */
class Page_Filter

{
	
	/**
	 * 过滤扩展接口
	 */
	static interface FilterExtends {
		com.querydsl.core.types.Predicate gainName(
			String name
		);
		com.querydsl.core.types.Predicate gainType(
			bairui.international.model.type.Type_ElectronicTicket type
		);
		com.querydsl.core.types.Predicate gainGiveFlag(
			Boolean giveFlag
		);
		com.querydsl.core.types.Predicate gainOneuseFlag(
			Boolean oneuseFlag
		);
		com.querydsl.core.types.Predicate gainExpiryDate_start(
			java.util.Date expiryDate
		);
		com.querydsl.core.types.Predicate gainExpiryDate_end(
			java.util.Date expiryDate
		);
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_ElectronicTicket QRoot,
		javax.servlet.http.HttpServletRequest request
		,FilterExtends filterExtends
	) {
		com.querydsl.core.BooleanBuilder query = query(
				QRoot
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("number"), 
						String.class, 
						"yyyy-MM-dd"
					)
	,			com.sh_lianjing.string.util.Util_String.parseToType(
						request.getParameter("state"), 
						bairui.international.model.status.State_ElectronicTicket.class, 
						"yyyy-MM-dd"
					)
			);
			/* comment 附加过滤属性 */
			if(null != request.getParameter("name")){
				query.and(filterExtends.gainName(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("name"), 
							String.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("type")){
				query.and(filterExtends.gainType(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("type"), 
							bairui.international.model.type.Type_ElectronicTicket.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("giveFlag")){
				query.and(filterExtends.gainGiveFlag(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("giveFlag"), 
							Boolean.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("oneuseFlag")){
				query.and(filterExtends.gainOneuseFlag(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("oneuseFlag"), 
							Boolean.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("expiryDate_start")){
				query.and(filterExtends.gainExpiryDate_start(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("expiryDate_start"), 
							java.util.Date.class, 
							"yyyy-MM-dd"
						)
				));
			}
			if(null != request.getParameter("expiryDate_end")){
				query.and(filterExtends.gainExpiryDate_end(
					com.sh_lianjing.string.util.Util_String.parseToType(
							request.getParameter("expiryDate_end"), 
							java.util.Date.class, 
							"yyyy-MM-dd"
						)
				));
			}
	;
		return query;
	}
	
	final static com.querydsl.core.BooleanBuilder query(
		bairui.international.model.domain.jpa.QTB_ElectronicTicket QRoot
	,	String number
	,	bairui.international.model.status.State_ElectronicTicket state
	) {
		com.querydsl.core.BooleanBuilder builder = new com.querydsl.core.BooleanBuilder();
	
		if(null != number){
			builder.and(QRoot.number.like("%"+number+"%"));
		}
		if(null != state){
			builder.and(QRoot.state.eq(state));
		}
		return builder;
	}
	
}
